/*package br.fbc.magno;



import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.json.JSONArray;
import org.json.JSONObject;

import br.com.freedom.exception.SocialMediaException;
import br.com.freedom.model.User;
import br.com.freedom.util.Configuration;

import com.google.code.facebookapi.FacebookJsonRestClient;
import com.google.code.facebookapi.FacebookWebappHelper;

public class Facebook implements SocialMedia {
	
	public static final String API_KEY="";
	private final String SECRET_KEY="";
	private FacebookJsonRestClient facebookClient;
	private FacebookWebappHelper<Object> facebookAppHelp;
	private HttpServletRequest request;
	
	public Facebook(HttpServletRequest request, HttpServletResponse response) {
		this.request = request;
		facebookAppHelp = FacebookWebappHelper.newInstanceJson(request, response, API_KEY, SECRET_KEY);
		facebookClient = (FacebookJsonRestClient) facebookAppHelp.getFacebookRestClient();
	}
	 
	
	public boolean isLoged(){
		if(request.getParameter("fb_sig_user") != null)
			return true;
		else
			return false;
	}

	
	public User getUser(String id) throws SocialMediaException {
		User user = null;

		try {
			
			Set<String> listFields = new HashSet<String>();
			listFields.add("name");
			listFields.add("email");
			listFields.add("pic_small");
			listFields.add("pic_big");
			listFields.add("pic");
			listFields.add("username");
			listFields.add("locale");
			listFields.add("current_location");
			
			List<Long> listUids = new ArrayList<Long>();
			listUids.add(Long.valueOf(id));
			
			JSONArray result = facebookClient.users_getInfo(listUids, listFields);
			
			if ( result != null ){
				JSONObject object = result.getJSONObject(0);
				int level = Integer.parseInt(Configuration.getInstance().getParameter("aplication.user.initial.idLevel"));
				
				user = new User();
				user.setUserName(String.valueOf(id));
				user.setName(object.getString("name"));
				user.setImageLarge(object.getString("pic_big"));
				user.setImageMedium(object.getString("pic"));
				user.setImageSmall(object.getString("pic_small"));
				user.setPassword("");
				user.setCredits(Float.parseFloat(Configuration.getInstance().getParameter("aplication.user.initial.credits")));
				user.setLevel(level);
				user.setIdFacebook(id);
				user.setLocale(object.getString("locale"));
				user.setEmail(object.getString("email"));
				if ( object.getJSONObject("current_location") != null ){
					user.setCountry(object.getJSONObject("current_location").getString("country"));
					user.setCity(object.getJSONObject("current_location").getString("city"));
					user.setState(object.getJSONObject("current_location").getString("state"));
				}
			}
			
		} catch (Exception error) {
			new SocialMediaException("Erro ao tentar buscar os dados do usuario no facebook", error);
		}
		
		return user;
	}

}
 
*/